<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="../../base.jsp"></jsp:include>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>

<script type="text/javascript">
	function checkUserIsExist() {
		var userName = $('#userName').val();
		$.ajax({
			   type: "POST",
			   url: "/S3H3L3/userInfo/checkUserIsExist.do",
			   contentType : 'application/json',
			   data: JSON.stringify(userName),
			   success: function(data){
				   if (data.data == true) {
					   alert('用户名已存在，请重新输入其它用户名！');
					   $('#userName').val('');
				   }
			   },
			   error:function(){
				      alert("请求失败");
				     }
			});
	}
</script>

</head>
<body>
<form action="/S3H3L3/userInfo/addUser.do" method="post">
	<input type="hidden" value="123" id="password" name="password">
	<table>
		<tr>
			<td colspan="2" align="center"><h1>添加用户</h1></td>
		</tr>
		<tr>
			<td align="right"><label>用户名:</label></td>
			<td>
				<label>
					<input id="userName" name="userName" width="200px;" class="easyui-validatebox" onchange="checkUserIsExist()" required="true"/>
				</label>
			</td>
		</tr>
		<tr>
			<td align="right"><label>性别:</label></td>
			<td>
				<input id="sex1" name="sex" type="radio" value="1" checked="checked"/><label for="sex1">男</label>
				<input id="sex2" name="sex" type="radio" value="0"/><label for="sex2">女</label>
			</td>
		</tr>
		<tr>
			<td align="right"><label>年龄:</label></td>
			<td><label><input id="age" name="age" width="200px;" class="easyui-validatebox" /></label></td>
		</tr>
		<tr>
			<td align="right"><label>角色:</label></td>
			<td>
				<input id="role1" name="role" type="radio" value="2" checked="checked"/><label for="role1">普通用户</label><br />
				<input id="role2" name="role" type="radio" value="3"/><label for="role2">用户管理员</label><br />
				<input id="role3" name="role" type="radio" value="4"/><label for="role3">新闻管理员</label>
			</td>
		</tr>
		<tr>
			<td align="right"><label>地址:</label></td>
			<td><label><input id="address" name="address" width="200px;" class="easyui-validatebox" /></label></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" value="提交"/><input type="reset" value="重置"/></td>
		</tr>
	</table>
</form>
</body>
</html>